package com.lcpress.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.lcpress.Interceptor.LoginInterceptor;

@Configuration
public class ControllerMvcConfig implements WebMvcConfigurer{
	
	@Value("${file.path}")
	private String path;
	
	@Value("${file.address}")
	private String address;
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// TODO Auto-generated method stub
		
		/*registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**")
															.excludePathPatterns("/adminuserop/login",
																	"/adminuserop/login_action",
																	"/static/**");*/
		WebMvcConfigurer.super.addInterceptors(registry);
	}
	
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler(path).addResourceLocations("classpath:/media/");
		registry.addResourceHandler("/static/**")
							.addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX+"/static/");
		WebMvcConfigurer.super.addResourceHandlers(registry);
	}

}
